package com.haredot.interceptor.properties;

import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.concurrent.TimeUnit;

/**
 * 默认1秒内不允许超过 5次
 */
@ConfigurationProperties(prefix = "ip.rate")
public class IpRateProperties {
    /**
     * 是否启用 IP 限流，默认启用
     */
    private boolean enable = true;
    /**
     * 间隔时间，默认 1秒
     */
    private long time = 1000;
    /**
     * 允许单位时间内最大访问次数
     */
    private long maxCount = 20;
    /**
     * 间隔时间单位，默认毫秒
     */
    private TimeUnit unit = TimeUnit.MILLISECONDS;

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public long getMaxCount() {
        return maxCount;
    }

    public void setMaxCount(long maxCount) {
        this.maxCount = maxCount;
    }

    public TimeUnit getUnit() {
        return unit;
    }

    public void setUnit(TimeUnit unit) {
        this.unit = unit;
    }

    public boolean isEnable() {
        return enable;
    }

    public void setEnable(boolean enable) {
        this.enable = enable;
    }
}
